﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SurveySystem.Master" AutoEventWireup="true" CodeBehind="ShowSurvey.aspx.cs" Inherits="SurveySystem.Web.ShowSurvey" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentPlaceholder" runat="server">
    <h2> Szavazás eredményei </h2>
    <p> A kérdés: </p>
    <h4> <asp:Label ID="questionLabel" runat="server"></asp:Label> </h4>
    
    <asp:ObjectDataSource ID="answerSummaryResource" runat="server" 
        SelectMethod="getSummaryAnswers" TypeName="SurveySystem.Core.SurveysBLL">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="-1" Name="surveyId" 
                QueryStringField="surveyId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:MultiView ID="ResultView" runat="server">
        <asp:View ID="resMultiSelectView" runat="server">
            <asp:GridView ID="resMultiView" runat="server" 
                DataSourceID="answerSummaryResource" 
                onrowdatabound="resMultiView_RowDataBound" AutoGenerateColumns="False" 
                CellPadding="4" ForeColor="#333333" GridLines="None">
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:BoundField DataField="Text" HeaderText="Lehetőség" SortExpression="Text" />
                    <asp:BoundField DataField="AnswerCount" HeaderText="Szavazatok száma" 
                        SortExpression="AnswerCount" />
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
        </asp:View>
        <asp:View ID="resSingleSelectView" runat="server">
            <asp:GridView ID="GridView1" runat="server" 
                DataSourceID="answerSummaryResource" AutoGenerateColumns="False" 
                CellPadding="4" ForeColor="#333333" GridLines="None">
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:BoundField DataField="Text" HeaderText="Lehetőség" SortExpression="Text" />
                    <asp:BoundField DataField="AnswerCount" HeaderText="Szavazatok száma" 
                        SortExpression="AnswerCount" />
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
        </asp:View>
        <asp:View ID="resTextView" runat="server">
            <asp:GridView ID="textGridView" runat="server" AutoGenerateColumns="False" 
                DataSourceID="ObjectDataSource2" CellPadding="4" ForeColor="#333333" 
                GridLines="None">
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:TemplateField HeaderText="Felhasználó">
                        <ItemTemplate>
                            <asp:Label runat="server" Text='<%# ((SurveySystem.Core.FreeAnswer)Container.DataItem).User.name %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="text" HeaderText="Válasz" SortExpression="text" />
                    
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                SelectMethod="getTextAnswers" TypeName="SurveySystem.Core.SurveysBLL">
                <SelectParameters>
                    <asp:QueryStringParameter DefaultValue="-1" Name="surveyId" 
                        QueryStringField="surveyId" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </asp:View>
    </asp:MultiView>
    <asp:MultiView ID="VoteView" runat="server" ActiveViewIndex="0">
        <asp:View ID="MultiSelectView" runat="server">
            <asp:CheckBoxList ID="MultiBox" runat="server" DataSourceID="ObjectDataSource1" 
                DataTextField="text" DataValueField="id" ondatabound="MultiBox_DataBound">
            </asp:CheckBoxList>
            <asp:CustomValidator ID="multiSelectValidator" runat="server" 
                ErrorMessage="Legalább egy lehetőséget válassz!"></asp:CustomValidator>
        </asp:View>
        <asp:View ID="SingleSelectView" runat="server">
            <asp:RadioButtonList ID="SingleBox" runat="server" 
                DataSourceID="ObjectDataSource1" DataTextField="text" DataValueField="id" 
                ondatabound="SingleBox_DataBound">
            </asp:RadioButtonList>
            <asp:CustomValidator ID="singleSelectValidator" runat="server" 
                ErrorMessage="Válassz egy lehetőséget!"></asp:CustomValidator>
            <br />
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                SelectMethod="GetChoices" TypeName="SurveySystem.Core.SurveysBLL">
                <SelectParameters>
                    <asp:QueryStringParameter Name="surveyId" QueryStringField="surveyId" 
                        Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </asp:View>
        <br />
        <asp:View ID="TextView" runat="server">
            <asp:TextBox ID="freeTextBox" runat="server" Columns="80" Height="200px" 
                Rows="10"></asp:TextBox>
            <asp:CustomValidator ID="TextValidator" runat="server" 
                ErrorMessage="CustomValidator"></asp:CustomValidator>
            <br />
            <asp:CustomValidator ID="textLengthValidator" runat="server" 
                ErrorMessage="Adja meg a válasz szövegét!"></asp:CustomValidator>
            <br />
        </asp:View>
    </asp:MultiView>
    <asp:Button ID="sendButton" runat="server" 
        Text="Szavazás" />
</asp:Content>
